package com.ttl.bc.master.dwr.service;

import java.util.List;

import com.ttl.bc.master.itemunit.BCItemUnitBean;
import com.ttl.bc.master.itemunit.BCItemUnitDAO;

public class BCItemUnitService {

	public BCItemUnitService() {

	}

	@SuppressWarnings("unchecked")
	public BCItemUnitBean getItemUnit(String id) {
		
		String hql = "FROM BCItemUnitBean p WHERE upper(p.code) =  '"+id.toUpperCase()+"' or name='"+id.toUpperCase()+"'";
		BCItemUnitBean bean = new BCItemUnitBean();		
		BCItemUnitDAO dao = new BCItemUnitDAO();
		List al = dao.find(hql);
//		System.out.println("id="+id+"===>"+al.size());
		if (al.size()>0) {
			bean = (BCItemUnitBean)al.get(0);
		//	System.out.println(bean.getCode());
		//	System.out.println(bean.getName());
		}				

		return bean;
	}
}
